;; -*- Emacs-Lisp -*-
;; Time-stamp: <2011-04-10 19:19:09 Sunday by lenovo>

(auto-insert-mode 1)

(defun auto-insert-settings ()
  ""
  (setq auto-insert-query nil)
  (setq auto-insert-directory my-emacs-templates-path)
  (define-auto-insert "build.properties" "build.properties.tpl")

  (defun expand-template (template)
    (template-expand-template (concat my-emacs-templates-path template)))

  (defun insert-headx-snippet ()
    (insert-snippet "headx"))

  (defun insert-abbrev (abbrev-name)
    (interactive "s")
    (insert abbrev-name)
    (expand-abbrev))

  (defun insert-snippet (snippet)
    (interactive "s")
    (insert snippet)
    (yas/expand))

  (mapc
   (lambda (suffix)
     (define-auto-insert (concat "\\." suffix "$") 'insert-headx-snippet))
   '("el" "sh" "org" "pl" "py" "htm\\(1\\)?")))

(eval-after-load "autoinsert"
  `(auto-insert-settings))

(provide 'auto-insert-settings)